package com.touchwp.java.wechat.message;

import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import com.touchwp.java.wechat.converter.CDATAAdapter;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "xml")
public class NewsMessage extends Message {
	private static final long serialVersionUID = 8344242921542321950L;

	@XmlElement(name = "Title")
	private String articleCount;

	@XmlElement(name = "item")
	@XmlElementWrapper(name="Articles")
	private List<Item> articles;

	@XmlAccessorType(XmlAccessType.FIELD)
	public static class Item {
		@XmlElement(name = "Title")
		@XmlJavaTypeAdapter(value = CDATAAdapter.class)
		private String title;

		@XmlElement(name = "Description")
		@XmlJavaTypeAdapter(value = CDATAAdapter.class)
		private String description;

		@XmlJavaTypeAdapter(value = CDATAAdapter.class)
		@XmlElement(name = "PicUrl")
		private String picUrl;

		@XmlJavaTypeAdapter(value = CDATAAdapter.class)
		@XmlElement(name = "Url")
		private String url;

		public Item() {
		}

		public String getTitle() {
			return this.title;
		}

		public void setTitle(String title) {
			this.title = title;
		}

		public String getDescription() {
			return this.description;
		}

		public void setDescription(String description) {
			this.description = description;
		}

		public String getPicUrl() {
			return this.picUrl;
		}

		public void setPicUrl(String picUrl) {
			this.picUrl = picUrl;
		}

		public String getUrl() {
			return this.url;
		}

		public void setUrl(String url) {
			this.url = url;
		}

		@Override
		public String toString() {
			return String.format("Item [title=%s, description=%s, picUrl=%s, url=%s]", title, description, picUrl, url);
		}

	}

	public String getArticleCount() {
		return this.articleCount;
	}

	public void setArticleCount(String articleCount) {
		this.articleCount = articleCount;
	}

	public List<Item> getArticles() {
		return this.articles;
	}

	public void setArticles(List<Item> articles) {
		this.articles = articles;
	}

	@Override
	public String toString() {
		return String.format("NewsMessage [articleCount=%s, articles=%s]", articleCount, articles);
	}

}
